﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KL.UFrame.Data.Entities
{
    public class Trainning:CurdEntityBase
    {
        [Required]
        public int CategoryId { get; set; }

        [ForeignKey("CategoryId")]
        public TrainningCategory Category { get; set; }

        [Required]
        [StringLength(50)]
        public string Title { get; set; }

        [Required]
        [Range(1,int.MaxValue)]
        public int UserLimit { get; set; }

        public IList<Enroll> Enrolls { get; set; } 
    }


    public class TrainningCategory:CurdEntityBase
    {
        [Required]
        [StringLength(50)]
        public string Name { get; set; }

        public IList<Trainning> Trainnings { get; set; }
    }

    public class Enroll
    {
        [Key]
        public int Id { get; set; }

        [Required]
        [StringLength(50)]
        public string Name { get; set; }

        [Required]
        [StringLength(18)]
        [Column(TypeName = "char")]
        public string  IdCard  { get; set; }

        [Required]
        public int Gender { get; set; }

        [Required]
        public int Age { get; set; }

        [Required]
        [StringLength(11,MinimumLength = 11)]
        [Column(TypeName = "char")]
        public string Phone { get; set; }

        [Required]
        public int TrainningId { get; set; }

        [ForeignKey("TrainningId")]
        public Trainning Trainning { get; set; }

        [Required]
        public DateTime CreateTime { get; set; }

        [Required]
        public EnrollStatus EnrollStatus { get; set; }

        [StringLength(200)]
        public string StatusDescription { get; set; }
    }

    public enum EnrollStatus
    {
        New=0,
        Pass=1,
        Failed=2
    }
}
